<template>
  <div>

  </div>
</template>


<script>
export default {
  data() {
    return {

    }
  },
  created() {
    this.sm2Test();

  },
  mounted() {

  },
  methods: {
    sm2Test() {
      const sm2 = require('sm-crypto').sm2;
      let keypair = sm2.generateKeyPairHex()

      let publicKey = keypair.publicKey // 公钥
      let privateKey = keypair.privateKey // 私钥
      console.log("公钥：", publicKey);
      console.log("私钥：", privateKey);
      // 公钥： 0438cb71399e2d63f51d71d01fb5c1863ba2a860d0e0edd22e77262390e9a7eaec445c5ba13c43c129be51254c40cb17cea4570acf3f62351fa2f1aee999c61362
      // 私钥： 4640376af34ec11b452df349c25c22f63b93c8650ca1629dc9eafdd52adb56e2
      let encryptData = sm2.doEncrypt("123456", publicKey, 1) // 加密结果
      console.log(encryptData);
      

    }
  },
}
</script>
<style lang="scss" scoped>
</style>>